Add PyInstaller --onefile support via centralized resource_path() #424
+742
−256
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hardcoded
os.path.dirname(__file__)paths fail in PyInstaller --onefile builds because__file__points to source locations, not the temporary_MEIPASSextraction folder. This breaks ONNX model loading and config file access at runtime.Changes
Core implementation
resource_path()tosrc/utils/resource_manager.pythat detectssys._MEIPASSand returns correct paths for both development and frozen modessrc/utils/__init__.pyModel loading updates
resource_path()for all ONNX model paths:node_classification.py(5 models)node_object_detection.py(7 models)node_semantic_segmentation.py(4 models)node_pose_estimation.py(3 models)node_face_detection.py(1 model)node_low_light_image_enhancement.py(6 models)node_monocular_depth_estimation.py(4 models)node/DLNode/object_detection/YOLOX/yolox.pyto loadcoco_classes.txtusingresource_path()Documentation
verify_pyinstaller_portability.pyExample
Before:
After:
The function automatically resolves to
sys._MEIPASSwhen frozen, or project root in development. All 20+ ONNX models now load correctly in PyInstaller executables.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.